#ifndef __CAPICON_H
#define __CAPICON_H

#include <fstream>
#include "mainfrm.h"
#include "resource.h"
#include "capiobj.h"
#include <boost/iostreams/concepts.hpp>

class wbuf : public boost::iostreams::sink
{
public:
    wbuf( CEdit *pedit ) : m_pedit( pedit ) {}
    std::streamsize write( const char *sz, std::streamsize n );

private:
    CEdit *m_pedit;
};

class CCapiConApp : public CWinApp
{
public:
    CCapiConApp() : pcapi(0) {}
    CCapiConApp::~CCapiConApp();

    void CmdLine( const std::string& sCmdLine );

    char szOwnNumber[200];
    unsigned short wBNumber;
    CAPI *pcapi;
    
    unsigned char *aDtmf;
    unsigned long nDtmfBufSize;

    static void StaticCallBack( void *_, const _API_MSG& msg ) { ((CCapiConApp *)_)->CallBack( msg ); }
    void CallBack( const _API_MSG& msg );

    bool IsBRI() { return wBNumber <= 3; }

public:
    //{{AFX_VIRTUAL(CCapiConApp)
    virtual BOOL InitInstance();
    //}}AFX_VIRTUAL

public:
    //{{AFX_MSG(CCapiConApp)
    afx_msg void OnAppAbout();
    afx_msg void OnEditCut();
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()

private:
    std::ostream *plogstream() { return apws.get(); }
    std::auto_ptr<std::ostream> apws;
};

#endif // __CAPICON_H
